package com.shihang.crm.service;

import com.shihang.crm.bean.Customer;
import com.shihang.crm.bean.LinkMan;
import com.shihang.crm.dao.LinkManDao;
import com.shihang.crm.utils.PageBean;
import org.hibernate.criterion.DetachedCriteria;

import java.util.List;

public class LinkManServiceImpl implements LinkManService{

    private LinkManDao ld;

    @Override
    public void save(LinkMan linkMan) {
        ld.save(linkMan);
    }


    @Override
    public PageBean getPageBean(DetachedCriteria dc, int currentPage, int pageSize) {
        //1.调用dao查询总记录
        int totalCount = ld.getTotalCount(dc);
        //2.创建pageBean对象
        PageBean pageBean = new PageBean(currentPage,totalCount,pageSize);
        //3调用dao查询分页列表
        List<LinkMan> list = ld.getPageList(dc,pageBean.getStart(),pageBean.getPageSize());
        //4.列表数据放入pageBean中
        pageBean.setList(list);
        return pageBean;
    }

    public void setLd(LinkManDao ld) {
        this.ld = ld;
    }
}
